/*
 * @Author: Clark
 * @Email: haixuanwoTxh@gmail.com
 * @Date: 2023-01-28 14:50:24
 * @LastEditors: Clark
 * @LastEditTime: 2023-01-28 15:33:25
 * @Description: file content
 */
#include "apue.h"
#include <pthread.h>

int makethread(void *(*fn)(void*), void *arg)
{
    pthread_t tid;
    pthread_attr_t attr;

    int err = pthread_attr_init(&attr);
    if (0 != err)
    {
        return err;
    }

    err = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
    if (0 == err)
    {
        err = pthread_create(&tid, &attr, fn, arg);
    }

    pthread_attr_destroy(&attr);
    return err;
}
